//
//  ZCXPetPictureCollectionViewCell.m
//  LoveOfPet
//
//  Created by dllo on 15/11/18.
//  Copyright © 2015年 孔维. All rights reserved.
//

#import "ZCXPetPictureCollectionViewCell.h"
#import "ZCXFirstActivityDetialTableViewCell.h"
#define HEIGHT  [[UIScreen mainScreen]bounds].size.height / 667
#define WIDTH   [[UIScreen mainScreen]bounds].size.width / 375
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>
@interface ZCXPetPictureCollectionViewCell ()
@property (nonatomic, retain) UIImageView *imageV;
@property (nonatomic, retain) UILabel *feelLabel; 
@end

@implementation ZCXPetPictureCollectionViewCell
- (void)dealloc{
    [_feelLabel release];
    [_imageV release];
    [_petModel release];
    [super dealloc];
}
- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageV = [[UIImageView alloc]init];
        [self.contentView addSubview:_imageV];
        [_imageV release];
        
        self.feelLabel = [[UILabel alloc]init];
        [self.contentView addSubview:_feelLabel];
        [_feelLabel release];
        
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 3 * WIDTH;
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    
    _imageV.frame = CGRectMake(5 * WIDTH, 5 * HEIGHT, self.frame.size.width - 10 * WIDTH, self.frame.size.height - 15 * HEIGHT - self.Heigth);
    
    
    _feelLabel.frame = CGRectMake(5 * WIDTH, self.frame.size.height - 5 * HEIGHT - self.Heigth, self.frame.size.width - 10 * WIDTH, self.Heigth);
    _feelLabel.font = [UIFont systemFontOfSize:15 * WIDTH];
    _feelLabel.textColor = [UIColor grayColor];
    _feelLabel.lineBreakMode = NSLineBreakByCharWrapping;
    _feelLabel.numberOfLines = 0;
}
- (void)setPetModel:(ZCXPetPictureModel *)petModel{
    if (_petModel != petModel) {
        [_petModel release];
        _petModel = [petModel retain];
    }
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:petModel.middle_url]];
    _feelLabel.text = petModel.Description;
    self.Heigth = [ZCXFirstActivityDetialTableViewCell heigthOfmessageLabel:self.feelLabel.text andFont:[UIFont systemFontOfSize:15 * WIDTH] andWidth:self.feelLabel.frame.size.width];
}

@end
